
version 15
capture log close
set more off
clear
clear matrix
clear mata

if c(username)=="WB485280" {
		glo rootdir		"C:\Users\wb485280\OneDrive - WBG\radicalization"
		}
if c(username)=="WB382635" {
		glo rootdir		"C:\Users\wb382635\Dropbox\Unemp & daesh"
		}
if c(username)=="WB452275" {
		glo rootdir		"C:\Users\WB452275\Dropbox\Projects\Unemp & daesh"
		}
if c(username)=="sarurchaudhary" {
		glo rootdir		"/Users/sarurchaudhary/Dropbox/Unemp & daesh"
		}
if c(username)=="kartikabhatia" {
			glo rootdir		"/Users/kartikabhatia/Dropbox/Before2019/Unemp & daesh"
			}
			
		glo	datadir     "${rootdir}/Data/Raw data"
		glo outdir		"${rootdir}/Data/Working datasets"
		glo dodir		"${rootdir}/Dofiles"
        
		cd "${outdir}"
		
	    log using wv6_prep, replace t


* ------------------------------------------------------------------------------
* Date : July 2017 [chkd oct 2021]


* Project : Mena Economic Monitor, Fall 2016 edition (MNACE, The World Bank)


* This do file prepares the WVS database for merge

* Database used : WV6_Stata_v_2016_01_01.dta.dta


* Output : wv6.dta

* ------------------------------------------------------------------------------



*                      ---------------------------------
*                      --------World Values Data--------
*                      ---------------------------------


use "${datadir}/WV6_Stata_v_2016_01_01.dta", clear

*           =================
*           Variables to keep
*           =================

 rename V* v*
 
********************************************
*Radicalization Variable
********************************************

/* A lot worse off A lot better off
1 2 3 4 5 6 7 8 9 10
(Show Card AA)
Please tell me for each of the following actions whether you think it can always 
 be justified, never be justified, or something in between, using this card. 
 
 v210 violence against other people */
 
 recode v210 (-1=.a) (-2=.b) (-5=.)
  tab v210, gen(wv_viol_others)


********************************************
*Independent Variables
********************************************

***Gender

/*v240 Gender
 1 "1 male"
   2 "2 female" */
recode v240 (-5=.) (-2=.b)
tab v240, gen(wv_gender)

***Age

*v242 AGE: Please tell me your age.
recode v242 (-1=.a) (-2=.b) (-5=.) (-3=.)


***Income

/*V239. On this card is an income scale on which 1 indicates the lowest income group
 and 10 the highest income group in your country. We would like to know in what group
 your household is. Please,specify the appropriate number, counting all wages, 
 salaries, pensions and other incomes that come in. (Code one number):
Lowest group Highest group
1 2 3 4 5 6 7 8 9 10 */

recode v239 (-1=.a) (-2=.b) (-5=.)
tab v239, gen(wv_income)

  
***Religion

/* v9 Religion
For each of the following, indicate how important it is in your life. Would you say it is
   
   1 "1 very important"
   2 "2 rather imp"
   3 "3 not v imp"
   4 "4 not at all imp"; */
recode v9 (-1=.a) (-2=.b) (-5=.)
tab v9, gen(wv_religious) 
 
***Employment

/*V229. Are you employed now or not? If yes, about how many hours a week? If more than one job: only for
the main job (code one answer):
Yes, has paid employment:
Full time employee (30 hours a week or more) 1
Part time employee (less than 30 hours a week) 2
Self employed 3
No, no paid employment:
Retired/pensioned 4
Housewife not otherwise employed 5
Student 6
Unemployed 7
Other (write in):______________________ 8    */


recode v229 (-1=.a) (-2=.b) (-5=.) (-4=.) (-3=.), gen(temp2)
label define ps 1 "Full time employee" 2 "Part time employee" 3 "Self employed" ///
4 "Retired/pensioned" 5 "Housewife" 6 "student" 7 "unemployed" 8 "others" 
label values temp2 ps
tab temp2, gen(wv_emp_status)    

recode v229 (-1=.a) (-2=.b) (-5=.) (-4=.) (-3=.)(1=0) (3=1) (7=2) (4=3) (5=3) (6=3) (8=.), gen(emp_status)    
label define pstd 0 "full time"  1 "self-employed" 2 "unemployed/part-time" 3 "outofworkforce"
label values emp_status pstd
tab emp_status, gen(wv_emp)

***Education

/*V248. What is the highest educational level that you have attained? [NOTE: if respondent indicates to be a
student, code highest level she expects to complete]:
1 No formal education
2 Incomplete primary school
3 Complete primary school
4 Incomplete secondary school: technical/vocational type
5 Complete secondary school: technical/vocational type
6 Incomplete secondary: university-preparatory type
7 Complete secondary: university-preparatory type
8 Some university-level education, without degree
9 University-level education, with degree */

 recode v248 (-1=.a) (-2=.b) (-5=.), gen(temp1)
  label define ph 1 "No formal education" 2 "Incomplete primary school"  3 "Complete primary school" ///
  4 "Incomplete secondary school: technical/vocational type" 5"Complete secondary school: technical/vocational type" 6 "Incomplete secondary: university-preparatory type" ///
  7 "Complete secondary: university-preparatory type" 8 "university without degree" 9 "univ with degree"
label values temp1 ph
 tab temp1, gen (wv_educ_status)
 
 recode v248 (-1=.a) (-2=.b) (-5=.)(1=0) (2=0) (3=0) (4=1) (5=1) (6=1) (7=1) (8=2) (9=2), gen (educ)
 label define phgd 0 "primary" 1 "secondary" 2 "tertiary" 
label values educ phgd
tab educ, gen (wv_educ)

* ------------------------------------------------------------------------------

* Collapsing data to create country level estimates (keeping the same labels)

drop temp1 temp2 educ emp_status

foreach v of var v242 wv_viol_others1 - wv_educ3 {
 	local l`v' : variable label `v'
        if `"`l`v''"' == "" {
 		local l`v' "`v'"
  	}
  }
collapse v242 wv_viol_others1 - wv_educ3 [pw=v258], by(v2 v262)


 foreach v of var v242 wv_viol_others1 - wv_educ3 {
 	label var `v' "`l`v''"
 }


* ------------------------------------------------------------------------------

* Renaming variables


decode v2, gen(country)
rename v262 year
rename v242 wv_age

sort country, stable

* Adding countries that are in WDI but not in WVS6

 insobs 111, before(1)
 replace country = "Afghanistan" in 1
 replace year = 2010 in 1
 replace country = "Albania" in 2
 replace year = 2010 in 2
 replace country = "Angola" in 3
 replace year = 2010 in 3
 replace country = "Austria" in 4
 replace year = 2010 in 4
 replace country = "Bangladesh" in 5
 replace year = 2010 in 5
 replace country = "Belgium" in 6
 replace year = 2010 in 6
 replace country= "Belize" in 7
 replace year = 2010 in 7
 replace country = "Benin" in 8
 replace year = 2010 in 8
 replace country = "Bhutan" in 9
 replace year = 2010 in 9
 replace country = "Bolivia" in 10
 replace year = 2010 in 10
 replace country = "Bosnia Herzegovina" in 11
 replace year = 2010 in 11
 replace country = "Botswana" in 12
 replace year = 2010 in 12
 replace country = "Bulgaria" in 13
 replace year = 2010 in 13
 replace country = "Burkina Faso" in 14
 replace year = 2010 in 14
 replace country = "Burundi" in 15
 replace year = 2010 in 15
 replace country= "Cambodia" in 16
 replace year = 2010 in 16
 replace country = "Cameroon" in 17
 replace year = 2010 in 17
 replace country = "Canada" in 18
 replace year = 2010 in 18
 replace country = "Central African Republic" in 19
 replace year = 2010 in 19
 replace country = "Chad" in 20
 replace year = 2010 in 20
 replace country = "Comoros" in 21
 replace year = 2010 in 21
 replace country = "Congo Brazzaville" in 22
 replace year = 2010 in 22
 replace country = "Congo Kinshasa" in 23
 replace year = 2010 in 23
 replace country = "Costa Rica" in 24
 replace year = 2010 in 24
 replace country = "Croatia" in 25
 replace year = 2010 in 25
 replace country= "Cuba" in 26
 replace year = 2010 in 26
 replace country = "Czech Republic" in 27
 replace year = 2010 in 27
 replace country = "Denmark" in 28
 replace year = 2010 in 28
 replace country = "Djibouti" in 29
 replace year = 2010 in 29
 replace country = "Dominican republic" in 30
 replace year = 2010 in 30
 replace country = "El Salvador" in 31
 replace year = 2010 in 31
 replace country = "Equatorial Guinea" in 32
 replace year = 2010 in 32
 replace country = "Eritrea" in 33
 replace year = 2010 in 33
 replace country = "Ethiopia" in 34
 replace year = 2010 in 34
 replace country = "Finland" in 35
 replace year = 2010 in 35
 replace country= "France" in 36
 replace year = 2010 in 36
 replace country = "Gabon" in 37
 replace year = 2010 in 37
 replace country = "Gambia, The" in 38
 replace year = 2010 in 38
replace country = "Greece" in 39
 replace year = 2010 in 39
 replace country = "Guatemala" in 40
 replace year = 2010 in 40
 replace country = "Guinea" in 41
 replace year = 2010 in 41
 replace country = "Guinea-Bissau" in 42
 replace year = 2010 in 42
 replace country = "Guyana" in 43
 replace year = 2010 in 43
 replace country = "Haiti" in 44
 replace year = 2010 in 44
 replace country = "Honduras" in 45
 replace year = 2010 in 45
 replace country= "Hungary" in 46
 replace year = 2010 in 46
 replace country = "Iceland" in 47
 replace year = 2010 in 47
 replace country = "Indonesia" in 48
 replace year = 2010 in 48
replace country = "Iran" in 49
 replace year = 2010 in 49
 replace country = "Ireland" in 50
 replace year = 2010 in 50
 replace country = "Israel" in 51
 replace year = 2010 in 51
 replace country = "Italy" in 52
 replace year = 2010 in 52
 replace country = "Ivory Coast" in 53
 replace year = 2010 in 53
 replace country = "Jamaica" in 54
 replace year = 2010 in 54
 replace country = "Kenya" in 55
 replace year = 2010 in 55
 replace country= "Kosovo" in 56
 replace year = 2010 in 56
 replace country = "Laos" in 57
 replace year = 2010 in 57
 replace country = "Latvia" in 58
 replace year = 2010 in 58
replace country = "Lesotho" in 59
 replace year = 2010 in 59
 replace country = "Liberia" in 60
 replace year = 2010 in 60
 replace country = "Lithuania" in 61
 replace year = 2010 in 61
 replace country = "Luxembourg" in 62
 replace year = 2010 in 62
 replace country = "Macedonia" in 63
 replace year = 2010 in 63
 replace country = "Madagascar" in 64
 replace year = 2010 in 64
 replace country = "Malawi" in 65
 replace year = 2010 in 65
 replace country= "Mali" in 66
 replace year = 2010 in 66
 replace country = "Malta" in 67
 replace year = 2010 in 67
 replace country = "Mauritania" in 68
 replace year = 2010 in 68
replace country = "Mauritius" in 69
 replace year = 2010 in 69
 replace country = "Moldova" in 70
 replace year = 2010 in 70
 replace country = "Mongolia" in 71
 replace year = 2010 in 71
 replace country = "Montenegro" in 72
 replace year = 2010 in 72
 replace country = "Mozambique" in 73
 replace year = 2010 in 73
 replace country = "Myanmar" in 74
 replace year = 2010 in 74
 replace country = "Nagorno Karbakh" in 75
 replace year = 2010 in 75
 replace country= "Namibia" in 76
 replace year = 2010 in 76
 replace country = "Nepal" in 77
 replace year = 2010 in 77
 replace country = "Nicargua" in 78
 replace year = 2010 in 78
 replace country = "Niger" in 79
 replace year = 2010 in 79
 replace country = "North Korea" in 80
 replace year = 2010 in 80
 replace country = "Northern Cyprus" in 81
 replace year = 2010 in 81
 replace country = "Norway" in 82
 replace year = 2010 in 82
 replace country = "Oman" in 83
 replace year = 2010 in 83
 replace country = "Panama" in 84
 replace year = 2010 in 84
 replace country = "Paraguay" in 85
 replace year = 2010 in 85
 replace country= "Portugal" in 86
 replace year = 2010 in 86
 replace country = "Puerto Rico" in 87
 replace year = 2010 in 87
 replace country = "Saudi Arabia" in 88
 replace year = 2010 in 88
 replace country = "Senegal" in 89
 replace year = 2010 in 89
 replace country = "Serbia" in 90
 replace year = 2010 in 90
 replace country = "Sierra Leone" in 91
 replace year = 2010 in 91
 replace country = "Slovakia" in 92
 replace year = 2010 in 92
 replace country = "Somalia" in 93
 replace year = 2010 in 93
 replace country = "Somaliland" in 94
 replace year = 2010 in 94
 replace country = "South Sudan" in 95
 replace year = 2010 in 95
 replace country= "Sri Lanka" in 96
 replace year = 2010 in 96
 replace country = "Sudan" in 97
 replace year = 2010 in 97
 replace country = "Suriname" in 98
 replace year = 2010 in 98
 replace country = "Swaziland" in 99
 replace year = 2010 in 99
 replace country = "Switzerland" in 100
 replace year = 2010 in 100
 replace country = "Syria" in 101
 replace year = 2010 in 101
 replace country = "Tajikistan" in 102
 replace year = 2010 in 102
 replace country = "Tanzania" in 103
 replace year = 2010 in 103
 replace country = "Togo" in 104
 replace year = 2010 in 104
 replace country = "Turkmenistan" in 105
 replace year = 2010 in 105
 replace country= "Uganda" in 106
 replace year = 2010 in 106
 replace country = "United Arab Emirates" in 107
 replace year = 2010 in 107
 replace country = "United Kingdom" in 108
 replace year = 2010 in 108
 replace country = "Venezuela" in 109
 replace year = 2010 in 109
 replace country = "Vietnam" in 110
 replace year = 2010 in 110
 replace country = "Zambia" in 111
 replace year = 2010 in 111
 
 
 * Creating numeric variable for countries

sort country, stable
encode country, gen(ctry)

sort ctry year

note: two regions missing from India 2012 (dnt have more info to comment on representativeness of India 2012) (WV6)

save "${outdir}/wv6.dta", replace

log close
